package bairui.international.weixin.portal.miniapp.controller.position.position;

import java.util.List;
import java.util.stream.Collectors;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lianjing.sh.spring.web.controller.base.action.Action;
import com.lianjing.sh.spring.web.controller.enhance.output.FomatOutput;

import bairui.international.model.domain.jpa.TB_Province;
import bairui.international.service.Service_Province;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 *
 * 省份列表
 *
 * @generated
 * 
 * @see STest_C_Position_ProvinceList_Get 测试
 *
 */
@Controller
public class C_Position_ProvinceList_Get
 extends SC_Position_ProvinceList_Get 
{
	
	@Autowired private Service_Province service_Province;
	
	/**
	 * Get请求
	 */
	@Action(Get.class)
	@GetMapping(Get.RequestMappingValue)
	public @FomatOutput @ResponseBody Object get(
		ModelMap map, HttpServletRequest request
	) throws Exception {
		List<TB_Province> provinces = service_Province.findAll();
		return provinces
				.stream()
				.map(it->new Output(it.getId(), it.getName()))
				.collect(Collectors.toList());
	}
	
	@AllArgsConstructor
	private static class Output { 
		@Getter private Long id;
		@Getter private String name;
	}

}
